#define  _CRT_SECURE_NO_WARNINGS
#include <string>
using namespace std;


class Solution {
public:
    int compare(string version1, string version2) {
        int pos1 = 0, pos2 = 0;
        while (pos1 < version1.size() && pos2 < version2.size())
        {
            size_t pointpos1 = version1.find_first_of('.', pos1);
            size_t pointpos2 = version1.find_first_of('.', pos2);

            if (pointpos1 == string::npos) pointpos1 = version1.size();
            if (pointpos2 == string::npos) pointpos2 = version2.size();

            int tmp1 = stoi(version1.substr(pos1, pointpos1 - pos1));
            int tmp2 = stoi(version2.substr(pos2, pointpos2 - pos2));


            if (tmp1 == tmp2)
            {
                pos1 = pointpos1 + 1;
                pos2 = pointpos2 + 1;
            }
            else if (tmp1 < tmp2)
                return -1;
            else return 1;
        }
        if (pos1 < version1.size()) return 1;
        else if (pos2 < version2.size()) return -1;
        return 0;
    }
};